package com.ktjy.lot.controller;

import com.ktjy.lot.service.impl.ApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class ApiContriller {

    @Autowired
    private ApiService apiService;

    @GetMapping("/test")
    public String testApiCall() {
        // 示例：调用GitHub API获取用户信息
        String url = "http://8.138.250.255:8081/purchase/purchase/page?pageNo=1&pageSize=10";
        var response = apiService.sendGetRequest(url, String.class);
        if (response.getStatusCode().is2xxSuccessful()) {
            return "API调用成功: " + response.getBody();
        } else {
            return "API调用失败: " + response.getStatusCode();
        }
    }
}